<?php
require('functions.php');
if(isset($_POST['submit'])){
	require('clases/variable.class.php');

	$var1 = htmlspecialchars(trim($_POST['var1']));	
	$valor = htmlspecialchars(trim($_POST['valor']));			
	$objVariables=new Variables;
	if ( $objVariables->insertar(array($var1, $valor)) == true){
		echo 'Datos guardados';
	}else{
		echo 'Se produjo un error. Intente nuevamente';
	} 
}else{
?>
<form id="frmVariableNuevo" name="frmVariableNuevo" method="post" action="nvariable.php" onsubmit="GrabarVariable(); return false;">
  <p><label>Variable<br />
  <input class="text" type="text" name="var1" id="var1" maxlength="50" />
  </label>
  </p>
  <p>
    <label>Valor<br />
    <input class="text" type="text" name="valor" id="valor" maxlength="160" />
    </label>
  </p>  
 
    <input type="submit" name="submit" id="button" value="Enviar" />
    <label></label>
    <input type="button" class="cancelar" name="cancelar" id="cancelar" value="Cancelar" onclick="Cancelar()" />
  </p>
 
</form>
<?php
}
?>